package com.e2edour.runtime.utils

import java.security.{MessageDigest}

/**
  * <p>
  * 签名帮助类
  *
  * @author King 
  * @since 2017/1/18
  */
object DigestUtil {

  def SHA1(decript: String): String = {

    var digest = MessageDigest.getInstance("SHA-1")
    digest.update(decript.getBytes("UTF-8"))
    val messageDigest = digest.digest
    // Create Hex String
    val hexString = new StringBuffer
    // 字节数组转换为 十六进制 数
    for (i <- 0 to messageDigest.length - 1) {
      val shaHex = Integer.toHexString(messageDigest(i) & 0xFF)
      if (shaHex.length < 2) {
        hexString.append(0)
      }
      hexString.append(shaHex)
    }
    return hexString.toString
  }
}
